/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package br.ufrj.arquitetura.view;

import br.ufrj.arquitetura.Arquitetura;
import br.ufrj.arquitetura.Dado;
import br.ufrj.arquitetura.Instrucao;

import java.awt.Color;
import java.awt.Component;
import java.awt.TextArea;
import java.awt.event.KeyEvent;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

import javax.swing.DefaultListModel;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileNameExtensionFilter;

public class View extends javax.swing.JFrame {

    private DefaultListModel<String> listModelInstructions;
    private DefaultListModel<String> listModelConstants;
    private DefaultListModel<String> listModelMemory;
    private Arquitetura arquitetura;
    
    /**
     * Creates new form View2
     */
    public View() {
        initComponents();
        
        listModelInstructions = new DefaultListModel<>();
        listModelConstants = new DefaultListModel<>();
        listModelMemory = new DefaultListModel<>();
        arquitetura = new Arquitetura();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings({ "rawtypes" })
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        txtR1 = new javax.swing.JTextField();
        txtR2 = new javax.swing.JTextField();
        txtR3 = new javax.swing.JTextField();
        txtR4 = new javax.swing.JTextField();
        txtR5 = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        txtPC = new javax.swing.JTextField();
        btExecuteNext = new javax.swing.JButton();
        btExecuteAll = new javax.swing.JButton();
        jScrollPane4 = new javax.swing.JScrollPane();
        listMemory = new javax.swing.JList();
        jLabel9 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        labelFilename = new javax.swing.JLabel();
        txtFlagZ = new javax.swing.JTextField();
        txtFlagC = new javax.swing.JTextField();
        txtFlagO = new javax.swing.JTextField();
        txtFlagN = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("R1:");

        jLabel2.setText("R2:");

        jLabel3.setText("R3:");

        jLabel4.setText("R4:");

        jLabel5.setText("R5:");

        txtR1.setEnabled(false);

        txtR2.setEnabled(false);

        txtR3.setEnabled(false);
        txtR3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtR3ActionPerformed(evt);
            }
        });

        txtR4.setEnabled(false);

        txtR5.setEnabled(false);

        jLabel6.setText("PC:");

        txtPC.setEnabled(false);

        btExecuteNext.setLabel("Proximo");
        btExecuteNext.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btExecuteNextActionPerformed(evt);
            }
        });

        btExecuteAll.setText("Executar Tudo");
        btExecuteAll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btExecuteAllActionPerformed(evt);
            }
        });

        jScrollPane4.setViewportView(listMemory);

        jLabel9.setText("Memoria");

        jButton1.setText("Abrir ...");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane2.setViewportView(jTextArea1);

        labelFilename.setText("Nenhum arquivo selecionado.");

        txtFlagZ.setEnabled(false);
        txtFlagZ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtFlagZActionPerformed(evt);
            }
        });

        txtFlagC.setEnabled(false);
        txtFlagC.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtFlagCActionPerformed(evt);
            }
        });

        txtFlagO.setEnabled(false);

        txtFlagN.setEnabled(false);

        jLabel7.setText("FlagZ:");

        jLabel8.setText("FlagC:");

        jLabel10.setText("FlagO:");

        jLabel11.setText("FlagN:");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 310, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(btExecuteNext, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btExecuteAll, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                    .addGap(84, 84, 84)
                                    .addComponent(jLabel8)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(txtFlagC, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jLabel10)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(txtFlagO, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jLabel11)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(txtFlagN, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addGap(99, 99, 99)
                                    .addComponent(jLabel2)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(txtR2, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jLabel3)))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jButton1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(labelFilename))
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(txtR3, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addComponent(jLabel4)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(txtR4, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jLabel5))
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addGroup(jPanel1Layout.createSequentialGroup()
                                                    .addComponent(jLabel7)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(txtFlagZ, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addGap(14, 14, 14))
                                                .addGroup(jPanel1Layout.createSequentialGroup()
                                                    .addComponent(jLabel1)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(txtR1, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                            .addGap(27, 27, 27)))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(txtR5, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jLabel6)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(txtPC, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(28, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel9)
                        .addGap(145, 145, 145))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtFlagZ, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtFlagC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtFlagO, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtFlagN, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7)
                    .addComponent(jLabel8)
                    .addComponent(jLabel10)
                    .addComponent(jLabel11)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(txtR1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtR2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3)
                            .addComponent(txtR3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtR4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5)
                            .addComponent(txtR5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6)
                            .addComponent(txtPC, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btExecuteAll, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(btExecuteNext, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton1)
                            .addComponent(labelFilename))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 344, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane4))
                .addContainerGap())
        );

        btExecuteNext.getAccessibleContext().setAccessibleName("Proximo");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    
    private void updateMemoryView()
    {
    	listModelMemory.clear();
    	
    	for(int i=0; i<Arquitetura.memoria.length; i++) {
    		String text = Arquitetura.memoria[i] != null ? Arquitetura.memoria[i].toString() : "[  ]";
    		listModelMemory.add(i, text);
    		System.out.println(i + "[" + text + "]");
    	}
    }
    
    @SuppressWarnings("unchecked")
	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        JFileChooser fileChooser = new JFileChooser();
        FileNameExtensionFilter filter = new FileNameExtensionFilter(
        "Assembly Files", "txt");
        fileChooser.setFileFilter(filter);
        int returnVal = fileChooser.showOpenDialog(this);
        if(returnVal == JFileChooser.OPEN_DIALOG) {
           labelFilename.setText(fileChooser.getSelectedFile().getName());   
           
           File arquivo = fileChooser.getSelectedFile();
           jTextArea1.setText("");

        int conteudoR1, conteudoR2, conteudoR3, conteudoR4, conteudoR5,conteudoPc;
        int conteudoFlagZ, conteudoFlagO, conteudoFlagN, conteudoFlagC;

           try {
        	   Arquitetura.reiniciaMemoria();
               BufferedReader in = new BufferedReader(new FileReader(arquivo));
               String str, texto = "";
               int i = 0;
               while((str = in.readLine()) != null){
                   texto += str + "\n";
                   Arquitetura.memoria[i] = new Instrucao(str, i);
                   System.out.println(Arquitetura.memoria[i]);
                   listModelMemory.addElement(str);

                   i++;
               }
               listMemory.setModel(listModelMemory);
               jTextArea1.setText(texto);
               in.close();
           } 
           catch (IOException ioe){
           }
           conteudoR1 = Arquitetura.getConteudoRegistrador("R1");
           txtR1.setText(conteudoR1+"");
           conteudoR2 = Arquitetura.getConteudoRegistrador("R2");
           txtR2.setText(conteudoR2+"");
           conteudoR3 = Arquitetura.getConteudoRegistrador("R3");
           txtR3.setText(conteudoR3+"");
           conteudoR4 = Arquitetura.getConteudoRegistrador("R4");
           txtR4.setText(conteudoR4+"");
           conteudoR5 = Arquitetura.getConteudoRegistrador("R5");
           txtR5.setText(conteudoR5+"");
           conteudoPc = Arquitetura.getPc();
           txtPC.setText(conteudoPc+"");
           conteudoFlagZ = Arquitetura.getFlagZ();
           txtFlagZ.setText(conteudoFlagZ+"");
           conteudoFlagN = Arquitetura.getFlagN();
           txtFlagN.setText(conteudoFlagN+"");
           conteudoFlagO = Arquitetura.getFlagO();
           txtFlagO.setText(conteudoFlagO+"");
           conteudoFlagC = Arquitetura.getFlagC();
           txtFlagC.setText(conteudoFlagC+"");

        
        }
        
        
        
	     listMemory.setSelectedIndex(0);
	     updateMemoryView();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void btExecuteAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btExecuteAllActionPerformed
        
    	int conteudoR1, conteudoR2, conteudoR3, conteudoR4, conteudoR5,conteudoPc;
        int conteudoFlagZ, conteudoFlagO, conteudoFlagN, conteudoFlagC;

        for (int i = 0; i < Arquitetura.memoria.length; i++){
    		if (Arquitetura.memoria[i] != null && Arquitetura.memoria[i] instanceof Instrucao){
    			Arquitetura.executaInstrucao((Instrucao)Arquitetura.memoria[i]);
    		}
    		
    	}
    	
                conteudoR1 = Arquitetura.getConteudoRegistrador("R1");
                txtR1.setText(conteudoR1+"");
                conteudoR2 = Arquitetura.getConteudoRegistrador("R2");
                txtR2.setText(conteudoR2+"");
                conteudoR3 = Arquitetura.getConteudoRegistrador("R3");
                txtR3.setText(conteudoR3+"");
                conteudoR4 = Arquitetura.getConteudoRegistrador("R4");
                txtR4.setText(conteudoR4+"");
                conteudoR5 = Arquitetura.getConteudoRegistrador("R5");
                txtR5.setText(conteudoR5+"");
                conteudoPc = Arquitetura.getPc();
                txtPC.setText(conteudoPc+"");
                conteudoFlagZ = Arquitetura.getFlagZ();
                txtFlagZ.setText(conteudoFlagZ+"");
                conteudoFlagN = Arquitetura.getFlagN();
                txtFlagN.setText(conteudoFlagN+"");
                conteudoFlagO = Arquitetura.getFlagO();
                txtFlagO.setText(conteudoFlagO+"");
                conteudoFlagC = Arquitetura.getFlagC();
                txtFlagC.setText(conteudoFlagC+"");

		updateMemoryView();
    }//GEN-LAST:event_btExecuteAllActionPerformed

    @SuppressWarnings("deprecation")
	private void btExecuteNextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btExecuteNextActionPerformed
        // TODO add your handling code here:
    	int conteudoR1, conteudoR2, conteudoR3, conteudoR4, conteudoR5, conteudoPc;
        int conteudoFlagZ, conteudoFlagO, conteudoFlagN, conteudoFlagC;
    	
        Arquitetura.executaProximaInstrucao();
        
        conteudoPc = Arquitetura.getPc();
		txtPC.setText(conteudoPc+"");
    	
	    conteudoR1 = Arquitetura.getConteudoRegistrador("R1");
		txtR1.setText(conteudoR1+"");
		conteudoR2 = Arquitetura.getConteudoRegistrador("R2");
	    txtR2.setText(conteudoR2+"");
		conteudoR3 = Arquitetura.getConteudoRegistrador("R3");
		txtR3.setText(conteudoR3+"");
		conteudoR4 = Arquitetura.getConteudoRegistrador("R4");
		txtR4.setText(conteudoR4+"");
		conteudoR5 = Arquitetura.getConteudoRegistrador("R5");
		txtR5.setText(conteudoR5+"");
        listMemory.setSelectedIndex(conteudoPc);
        txtPC.setText(conteudoPc+"");
        conteudoFlagZ = Arquitetura.getFlagZ();
        txtFlagZ.setText(conteudoFlagZ+"");
        conteudoFlagN = Arquitetura.getFlagN();
        txtFlagN.setText(conteudoFlagN+"");
        conteudoFlagO = Arquitetura.getFlagO();
        txtFlagO.setText(conteudoFlagO+"");
        conteudoFlagC = Arquitetura.getFlagC();
        txtFlagC.setText(conteudoFlagC+"");
        
        updateMemoryView();
        
    }//GEN-LAST:event_btExecuteNextActionPerformed

    private void txtR3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtR3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtR3ActionPerformed

    private void txtFlagCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtFlagCActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtFlagCActionPerformed

    private void txtFlagZActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtFlagZActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtFlagZActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(View.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(View.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(View.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(View.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new View().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btExecuteAll;
    private javax.swing.JButton btExecuteNext;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JLabel labelFilename;
    private javax.swing.JList listMemory;
    private javax.swing.JTextField txtFlagC;
    private javax.swing.JTextField txtFlagN;
    private javax.swing.JTextField txtFlagO;
    private javax.swing.JTextField txtFlagZ;
    private javax.swing.JTextField txtPC;
    private javax.swing.JTextField txtR1;
    private javax.swing.JTextField txtR2;
    private javax.swing.JTextField txtR3;
    private javax.swing.JTextField txtR4;
    private javax.swing.JTextField txtR5;
    // End of variables declaration//GEN-END:variables
}
